package com.xizimall.portal.service.impl;

import java.security.KeyStore.PrivateKeyEntry;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.xizimall.portal.pojo.Order;
import com.xizimall.portal.service.OrderService;
import com.xizimall.common.pojo.XizimallResult;
import com.xizimall.common.utils.HttpClientUtil;
import com.xizimall.common.utils.JsonUtils;
/**
 * 订单服务
 * <p>Title: OrderServiceImpl</p>
 * <p>Description: </p>
 * <p>华南理工大学研究生</p> 
 * @author	李隆熹
 * @date	2018年5月2日下午7:23:20
 * @version 1.0
 */
@Service
public class OrderServiceImpl implements OrderService {
    
	@Value("${ORDER_BASE_URL}")
	private String ORDER_BASE_URL;
	
	@Value("${ORDER_CREATE_URL}")
	private String ORDER_CREATE_URL;
	
	@Override
	public String createOrder(Order order) {
		String json = HttpClientUtil.doPostJson(ORDER_BASE_URL+ORDER_CREATE_URL,
				JsonUtils.objectToJson(order));
		XizimallResult result = XizimallResult.format(json);
		if(result.getStatus()==200){
			Object orderId = result.getData();
			return orderId.toString();
		}
		return "";
	}

}
